#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {
    sort(points.begin(), points.end());
    cout<<"The sorted points are: "<<endl;
    for(int i=0;i<points.size();i++)
    {
        cout<<points[i][0]<<" "<<points[i][1]<<endl;
    }
    int w_right = -1;
    int count=0;
    for(int i=0;i<points.size();i++)
    {
        //若遍历到当前点的横坐标大于最右边矩阵的右边界，则需要添加一个矩阵,并更新矩阵的右边界
        if(points[i][0] > w_right)
        {
            w_right = points[i][0]+w;
            count++;
        }
    }
    return count;        
}

int main()
{
    vector<vector<int>> points(4, vector<int>(2));
    int w;
    cout<<"Enter the points: "<<endl;
    for(int i=0;i<4;i++)
    {
        for(int j=0;j<2;j++)
            cin>>points[i][j];
    }
    cout<<"The points are: "<<endl;
    for(int i=0;i<4;i++)
    {
        for(int j=0;j<2;j++)
            cout<<points[i][j]<<" ";
        cout<<endl;
    }
    cout<<"w is :"<<endl;
    cin>>w;
    int count = minRectanglesToCoverPoints(points, w);
    cout<<"The count is: "<<count;
    return 0;
}